/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package com.hitechbangla.fctu.form;

import com.hitechbangla.fctu.base.Location;
import com.hitechbangla.fctu.base.aircraft.Aircraft;
import com.hitechbangla.fctu.base.aircraft.AircraftState;
import com.hitechbangla.fctu.base.aircraft.AircraftType;
import com.hitechbangla.fctu.base.base.Base;
import com.hitechbangla.fctu.training.NinetyDegreeAttack;
import fctu.simulator.HTB_MAIN;
import java.util.Timer;

/**
 *
 * @author InspireServe
 */
public class CGI extends javax.swing.JInternalFrame {

    /**
     * Creates new form AttackType
     */
    public CGI() {
        super("CGI", true, true, true, true);
        initComponents();
    }

    /**
     * This method is called from within the constructor to initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is always
     * regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        jInternalFrame1 = new javax.swing.JInternalFrame();
        jPanel1 = new javax.swing.JPanel();
        jLabel1 = new javax.swing.JLabel();
        jLabel3 = new javax.swing.JLabel();
        jComboBox1 = new javax.swing.JComboBox();
        jComboBoxBaseName = new javax.swing.JComboBox();
        jButton1 = new javax.swing.JButton();

        jInternalFrame1.setVisible(true);

        javax.swing.GroupLayout jInternalFrame1Layout = new javax.swing.GroupLayout(jInternalFrame1.getContentPane());
        jInternalFrame1.getContentPane().setLayout(jInternalFrame1Layout);
        jInternalFrame1Layout.setHorizontalGroup(
            jInternalFrame1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGap(0, 0, Short.MAX_VALUE)
        );
        jInternalFrame1Layout.setVerticalGroup(
            jInternalFrame1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGap(0, 0, Short.MAX_VALUE)
        );

        setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);
        setTitle("CGI");
        setAlwaysOnTop(true);

        jLabel1.setText("Attack Type");

        jLabel3.setText("Base");

        jComboBox1.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "90 Degree Attack"}));
        jComboBox1.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jComboBox1ActionPerformed(evt);
            }
        });

        jComboBoxBaseName.setModel(new javax.swing.DefaultComboBoxModel(HTB_MAIN.gameScene.getBaseListStringArray()));

        jButton1.setText("Ok");
        jButton1.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton1ActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1);
        jPanel1.setLayout(jPanel1Layout);
        jPanel1Layout.setHorizontalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel1Layout.createSequentialGroup()
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jPanel1Layout.createSequentialGroup()
                        .addGap(39, 39, 39)
                        .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(jLabel1)
                            .addComponent(jLabel3))
                        .addGap(18, 18, 18)
                        .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(jComboBoxBaseName, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(jComboBox1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)))
                    .addGroup(jPanel1Layout.createSequentialGroup()
                        .addGap(93, 93, 93)
                        .addComponent(jButton1)))
                .addContainerGap(59, Short.MAX_VALUE))
        );
        jPanel1Layout.setVerticalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel1Layout.createSequentialGroup()
                .addGap(35, 35, 35)
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel1)
                    .addComponent(jComboBox1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGap(22, 22, 22)
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel3)
                    .addComponent(jComboBoxBaseName, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGap(35, 35, 35)
                .addComponent(jButton1)
                .addContainerGap(35, Short.MAX_VALUE))
        );

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addComponent(jPanel1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(0, 2, Short.MAX_VALUE))
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(jPanel1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
        );

        pack();
    }// </editor-fold>//GEN-END:initComponents

    private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton1ActionPerformed
        // TODO add your handling code here:
        
        //
        Aircraft interCeptor;
        Aircraft target;
        String targetCallSign = "295";
        String interceptorCallSign = "196";
        int speedOfTarget = 825;
        int speedOfInterceptor = 890;
        int aircraftHalfDistance = 1;
        int airCraftHeight = 10;
        Base base = HTB_MAIN.gameScene.baseList.get(jComboBoxBaseName.getSelectedIndex());
        AircraftType type = HTB_MAIN.gameScene.airCraftTypeList.get(0);
        //target = new Aircraft(type, targetLocation);


        AircraftState state = new AircraftState(targetCallSign, new Location(base.getLocation().getX() - aircraftHalfDistance, base.getLocation().getY(), airCraftHeight), 0, speedOfTarget, 1000);
        //AircraftType type = gameScene.airCraftTypeList.get(jComboAircraftType.getSelectedIndex());
        target = new Aircraft(state, type);

        state = new AircraftState(interceptorCallSign, new Location(base.getLocation().getX() + aircraftHalfDistance, base.getLocation().getY(), airCraftHeight), 0, speedOfInterceptor, 1000);
        interCeptor = new Aircraft(state, type);
        
        //
        
        //HTB_MAIN.CGITimer = new Timer();
        //Timer t = new Timer();
        //NinetyDegreeAttack ninetyDegreeAttack = new NinetyDegreeAttack(t);
       // NinetyDegreeAttack ninetyDegreeAttack = new NinetyDegreeAttack(HTB_MAIN.CGITimer);
        //HTB_MAIN.CGITimer = t;
        
        //t.schedule(ninetyDegreeAttack, 1000);
       // HTB_MAIN.CGITimer.schedule(ninetyDegreeAttack, 1000);
        HTB_MAIN.gameScene.airCraftList.add(target);
        HTB_MAIN.gameScene.airCraftList.add(interCeptor);
        HTB_MAIN.gameScene.HTBParent.repaint();
        
        //start of saiful abu
        NinetyDegreeAttack phase0, phase1, phase2, phase3;
        HTB_MAIN.CGITimer = new Timer("saiful abu", false);
        phase0 = new NinetyDegreeAttack(target, interCeptor, HTB_MAIN.CGITimer);
        phase1 = new NinetyDegreeAttack(phase0);
        phase2 = new NinetyDegreeAttack(phase1);
        phase3 = new NinetyDegreeAttack(phase2);
        int milis = 1000;
        int interval = 10 * milis;
        HTB_MAIN.CGITimer.schedule(phase0, interval);
        interval += 80 * milis;
        HTB_MAIN.CGITimer.schedule(phase1, interval);
        interval += 40 * milis;
        HTB_MAIN.CGITimer.schedule(phase2, interval);
        interval += 35 * milis;
        HTB_MAIN.CGITimer.schedule(phase3, interval);
        //end of saiful abu
        this.dispose();
    }//GEN-LAST:event_jButton1ActionPerformed

    private void jComboBox1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jComboBox1ActionPerformed
        // TODO add your handling code here:
    }//GEN-LAST:event_jComboBox1ActionPerformed

    /**
     * @param args the command line arguments
     */
    public static void main(String args[]) {
        /* Set the Nimbus look and feel */
        //<editor-fold defaultstate="collapsed" desc=" Look and feel setting code (optional) ">
        /* If Nimbus (introduced in Java SE 6) is not available, stay with the default look and feel.
         * For details see http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html 
         */
        try {
            for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels()) {
                if ("Nimbus".equals(info.getName())) {
                    javax.swing.UIManager.setLookAndFeel(info.getClassName());
                    break;
                }
            }
        } catch (ClassNotFoundException ex) {
            java.util.logging.Logger.getLogger(CGI.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (InstantiationException ex) {
            java.util.logging.Logger.getLogger(CGI.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (IllegalAccessException ex) {
            java.util.logging.Logger.getLogger(CGI.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (javax.swing.UnsupportedLookAndFeelException ex) {
            java.util.logging.Logger.getLogger(CGI.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        }
        //</editor-fold>

        /* Create and display the form */
        java.awt.EventQueue.invokeLater(new Runnable() {
            public void run() {
                new CGI().setVisible(true);
            }
        });
    }
    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JButton jButton1;
    private javax.swing.JComboBox jComboBox1;
    private javax.swing.JComboBox jComboBoxBaseName;
    private javax.swing.JInternalFrame jInternalFrame1;
    private javax.swing.JLabel jLabel1;
    private javax.swing.JLabel jLabel3;
    private javax.swing.JPanel jPanel1;
    // End of variables declaration//GEN-END:variables

    private void setAlwaysOnTop(boolean b) {
        //throw new UnsupportedOperationException("Not yet implemented");
    }
}
